package objects;

/**
 * 
 * @author stephenbwilliamson
 */
public class Chromosome {

	private String name;
	private String source;
	private ValidPosition bounds;

	public Chromosome(String name, String source, int start, int end) {
		this.name = name;
		this.source = source;
		this.bounds = new ValidPosition(start, end);
	}

	public Chromosome(String name) {
		this.name = name;
		this.source = "";
		this.bounds = new ValidPosition(0, 0);
	}

	/**
	 * Checks to see if the supplied Gene lies within the current Chromosome.
	 * Note that the valid position compareTo method has been implemented so
	 * that if the supplied argument is the same or lies within the object, it
	 * will return 0.
	 * 
	 * @param gene
	 *            The gene to be tested to see if it has a Valid Position
	 * @return if the gene is inside of the Chromosome
	 */
	public boolean isValidPosition(Gene gene) {
		return (this.bounds.compareTo(gene.getValidPosition()) == 0);
	}

	public static Chromosome getChromosome(String chromosome) {
		return new Chromosome(chromosome);
	}

	public String getName() {
		return this.name;
	}

	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}

	public void setBounds(int start, int end) {
		bounds = new ValidPosition(start, end);
	}

	public ValidPosition getBounds() {
		return bounds;
	}

	@Override
	public String toString() {
		return this.name;
	}
}
